/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package de.hsmannheim.pepa.patientenportal.apanwep.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import de.hsmannheim.pepa.patientenportal.apanwep.model.chronik;
import de.hsmannheim.pepa.patientenportal.apanwep.model.chronikModel;
import de.hsmannheim.pepa.patientenportal.apanwep.model.chronikSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the chronik service. Represents a row in the &quot;chronik&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link de.hsmannheim.pepa.patientenportal.apanwep.model.chronikModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link chronikImpl}.
 * </p>
 *
 * @author Cedric Nana
 * @see chronikImpl
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.chronik
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.chronikModel
 * @generated
 */
@JSON(strict = true)
public class chronikModelImpl extends BaseModelImpl<chronik>
	implements chronikModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a chronik model instance should use the {@link de.hsmannheim.pepa.patientenportal.apanwep.model.chronik} interface instead.
	 */
	public static final String TABLE_NAME = "chronik";
	public static final Object[][] TABLE_COLUMNS = {
			{ "chronik_id", Types.BIGINT },
			{ "datetime", Types.VARCHAR },
			{ "message", Types.VARCHAR },
			{ "object", Types.VARCHAR },
			{ "participant", Types.VARCHAR },
			{ "user_id", Types.BIGINT },
			{ "event_date_time_at", Types.VARCHAR },
			{ "event_date_time_down", Types.VARCHAR },
			{ "event_action", Types.VARCHAR },
			{ "enable", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table chronik (chronik_id LONG not null primary key,datetime VARCHAR(75) null,message VARCHAR(75) null,object VARCHAR(75) null,participant VARCHAR(75) null,user_id LONG,event_date_time_at VARCHAR(75) null,event_date_time_down VARCHAR(75) null,event_action VARCHAR(75) null,enable LONG)";
	public static final String TABLE_SQL_DROP = "drop table chronik";
	public static final String ORDER_BY_JPQL = " ORDER BY chronik.chronik_id ASC";
	public static final String ORDER_BY_SQL = " ORDER BY chronik.chronik_id ASC";
	public static final String DATA_SOURCE = "apanwepDataSource";
	public static final String SESSION_FACTORY = "apanwepSessionFactory";
	public static final String TX_MANAGER = "apanwepTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.chronik"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.chronik"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static chronik toModel(chronikSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		chronik model = new chronikImpl();

		model.setChronik_id(soapModel.getChronik_id());
		model.setDatetime(soapModel.getDatetime());
		model.setMessage(soapModel.getMessage());
		model.setObject(soapModel.getObject());
		model.setParticipant(soapModel.getParticipant());
		model.setUser_id(soapModel.getUser_id());
		model.setEvent_date_time_at(soapModel.getEvent_date_time_at());
		model.setEvent_date_time_down(soapModel.getEvent_date_time_down());
		model.setEvent_action(soapModel.getEvent_action());
		model.setEnable(soapModel.getEnable());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<chronik> toModels(chronikSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<chronik> models = new ArrayList<chronik>(soapModels.length);

		for (chronikSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.de.hsmannheim.pepa.patientenportal.apanwep.model.chronik"));

	public chronikModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _chronik_id;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setChronik_id(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _chronik_id;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return chronik.class;
	}

	@Override
	public String getModelClassName() {
		return chronik.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("chronik_id", getChronik_id());
		attributes.put("datetime", getDatetime());
		attributes.put("message", getMessage());
		attributes.put("object", getObject());
		attributes.put("participant", getParticipant());
		attributes.put("user_id", getUser_id());
		attributes.put("event_date_time_at", getEvent_date_time_at());
		attributes.put("event_date_time_down", getEvent_date_time_down());
		attributes.put("event_action", getEvent_action());
		attributes.put("enable", getEnable());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long chronik_id = (Long)attributes.get("chronik_id");

		if (chronik_id != null) {
			setChronik_id(chronik_id);
		}

		String datetime = (String)attributes.get("datetime");

		if (datetime != null) {
			setDatetime(datetime);
		}

		String message = (String)attributes.get("message");

		if (message != null) {
			setMessage(message);
		}

		String object = (String)attributes.get("object");

		if (object != null) {
			setObject(object);
		}

		String participant = (String)attributes.get("participant");

		if (participant != null) {
			setParticipant(participant);
		}

		Long user_id = (Long)attributes.get("user_id");

		if (user_id != null) {
			setUser_id(user_id);
		}

		String event_date_time_at = (String)attributes.get("event_date_time_at");

		if (event_date_time_at != null) {
			setEvent_date_time_at(event_date_time_at);
		}

		String event_date_time_down = (String)attributes.get(
				"event_date_time_down");

		if (event_date_time_down != null) {
			setEvent_date_time_down(event_date_time_down);
		}

		String event_action = (String)attributes.get("event_action");

		if (event_action != null) {
			setEvent_action(event_action);
		}

		Long enable = (Long)attributes.get("enable");

		if (enable != null) {
			setEnable(enable);
		}
	}

	@JSON
	@Override
	public long getChronik_id() {
		return _chronik_id;
	}

	@Override
	public void setChronik_id(long chronik_id) {
		_chronik_id = chronik_id;
	}

	@JSON
	@Override
	public String getDatetime() {
		if (_datetime == null) {
			return StringPool.BLANK;
		}
		else {
			return _datetime;
		}
	}

	@Override
	public void setDatetime(String datetime) {
		_datetime = datetime;
	}

	@JSON
	@Override
	public String getMessage() {
		if (_message == null) {
			return StringPool.BLANK;
		}
		else {
			return _message;
		}
	}

	@Override
	public void setMessage(String message) {
		_message = message;
	}

	@JSON
	@Override
	public String getObject() {
		if (_object == null) {
			return StringPool.BLANK;
		}
		else {
			return _object;
		}
	}

	@Override
	public void setObject(String object) {
		_object = object;
	}

	@JSON
	@Override
	public String getParticipant() {
		if (_participant == null) {
			return StringPool.BLANK;
		}
		else {
			return _participant;
		}
	}

	@Override
	public void setParticipant(String participant) {
		_participant = participant;
	}

	@JSON
	@Override
	public long getUser_id() {
		return _user_id;
	}

	@Override
	public void setUser_id(long user_id) {
		_user_id = user_id;
	}

	@JSON
	@Override
	public String getEvent_date_time_at() {
		if (_event_date_time_at == null) {
			return StringPool.BLANK;
		}
		else {
			return _event_date_time_at;
		}
	}

	@Override
	public void setEvent_date_time_at(String event_date_time_at) {
		_event_date_time_at = event_date_time_at;
	}

	@JSON
	@Override
	public String getEvent_date_time_down() {
		if (_event_date_time_down == null) {
			return StringPool.BLANK;
		}
		else {
			return _event_date_time_down;
		}
	}

	@Override
	public void setEvent_date_time_down(String event_date_time_down) {
		_event_date_time_down = event_date_time_down;
	}

	@JSON
	@Override
	public String getEvent_action() {
		if (_event_action == null) {
			return StringPool.BLANK;
		}
		else {
			return _event_action;
		}
	}

	@Override
	public void setEvent_action(String event_action) {
		_event_action = event_action;
	}

	@JSON
	@Override
	public long getEnable() {
		return _enable;
	}

	@Override
	public void setEnable(long enable) {
		_enable = enable;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			chronik.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public chronik toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (chronik)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		chronikImpl chronikImpl = new chronikImpl();

		chronikImpl.setChronik_id(getChronik_id());
		chronikImpl.setDatetime(getDatetime());
		chronikImpl.setMessage(getMessage());
		chronikImpl.setObject(getObject());
		chronikImpl.setParticipant(getParticipant());
		chronikImpl.setUser_id(getUser_id());
		chronikImpl.setEvent_date_time_at(getEvent_date_time_at());
		chronikImpl.setEvent_date_time_down(getEvent_date_time_down());
		chronikImpl.setEvent_action(getEvent_action());
		chronikImpl.setEnable(getEnable());

		chronikImpl.resetOriginalValues();

		return chronikImpl;
	}

	@Override
	public int compareTo(chronik chronik) {
		long primaryKey = chronik.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof chronik)) {
			return false;
		}

		chronik chronik = (chronik)obj;

		long primaryKey = chronik.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<chronik> toCacheModel() {
		chronikCacheModel chronikCacheModel = new chronikCacheModel();

		chronikCacheModel.chronik_id = getChronik_id();

		chronikCacheModel.datetime = getDatetime();

		String datetime = chronikCacheModel.datetime;

		if ((datetime != null) && (datetime.length() == 0)) {
			chronikCacheModel.datetime = null;
		}

		chronikCacheModel.message = getMessage();

		String message = chronikCacheModel.message;

		if ((message != null) && (message.length() == 0)) {
			chronikCacheModel.message = null;
		}

		chronikCacheModel.object = getObject();

		String object = chronikCacheModel.object;

		if ((object != null) && (object.length() == 0)) {
			chronikCacheModel.object = null;
		}

		chronikCacheModel.participant = getParticipant();

		String participant = chronikCacheModel.participant;

		if ((participant != null) && (participant.length() == 0)) {
			chronikCacheModel.participant = null;
		}

		chronikCacheModel.user_id = getUser_id();

		chronikCacheModel.event_date_time_at = getEvent_date_time_at();

		String event_date_time_at = chronikCacheModel.event_date_time_at;

		if ((event_date_time_at != null) && (event_date_time_at.length() == 0)) {
			chronikCacheModel.event_date_time_at = null;
		}

		chronikCacheModel.event_date_time_down = getEvent_date_time_down();

		String event_date_time_down = chronikCacheModel.event_date_time_down;

		if ((event_date_time_down != null) &&
				(event_date_time_down.length() == 0)) {
			chronikCacheModel.event_date_time_down = null;
		}

		chronikCacheModel.event_action = getEvent_action();

		String event_action = chronikCacheModel.event_action;

		if ((event_action != null) && (event_action.length() == 0)) {
			chronikCacheModel.event_action = null;
		}

		chronikCacheModel.enable = getEnable();

		return chronikCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(21);

		sb.append("{chronik_id=");
		sb.append(getChronik_id());
		sb.append(", datetime=");
		sb.append(getDatetime());
		sb.append(", message=");
		sb.append(getMessage());
		sb.append(", object=");
		sb.append(getObject());
		sb.append(", participant=");
		sb.append(getParticipant());
		sb.append(", user_id=");
		sb.append(getUser_id());
		sb.append(", event_date_time_at=");
		sb.append(getEvent_date_time_at());
		sb.append(", event_date_time_down=");
		sb.append(getEvent_date_time_down());
		sb.append(", event_action=");
		sb.append(getEvent_action());
		sb.append(", enable=");
		sb.append(getEnable());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(34);

		sb.append("<model><model-name>");
		sb.append("de.hsmannheim.pepa.patientenportal.apanwep.model.chronik");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>chronik_id</column-name><column-value><![CDATA[");
		sb.append(getChronik_id());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>datetime</column-name><column-value><![CDATA[");
		sb.append(getDatetime());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>message</column-name><column-value><![CDATA[");
		sb.append(getMessage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>object</column-name><column-value><![CDATA[");
		sb.append(getObject());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>participant</column-name><column-value><![CDATA[");
		sb.append(getParticipant());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>user_id</column-name><column-value><![CDATA[");
		sb.append(getUser_id());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>event_date_time_at</column-name><column-value><![CDATA[");
		sb.append(getEvent_date_time_at());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>event_date_time_down</column-name><column-value><![CDATA[");
		sb.append(getEvent_date_time_down());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>event_action</column-name><column-value><![CDATA[");
		sb.append(getEvent_action());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>enable</column-name><column-value><![CDATA[");
		sb.append(getEnable());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = chronik.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			chronik.class
		};
	private long _chronik_id;
	private String _datetime;
	private String _message;
	private String _object;
	private String _participant;
	private long _user_id;
	private String _event_date_time_at;
	private String _event_date_time_down;
	private String _event_action;
	private long _enable;
	private chronik _escapedModel;
}